import time

# 1不用函数（闭包）

start = time.time()

time.sleep(2)

end = time.time()

print(end - start)


# 2使用函数

def cal_time(func):
    start = time.time()
    func()
    end = time.time()
    print(end - start)


def t():
    time.sleep(3)


cal_time(t)
